//package com.zxm.dubbodemo.consumer.config;//
//// Source code recreated from a .class file by IntelliJ IDEA
//// (powered by Fernflower decompiler)
////
//
//
//import org.apache.commons.logging.Log;
//import org.apache.commons.logging.LogFactory;
//import org.springframework.boot.context.event.ApplicationReadyEvent;
//import org.springframework.cloud.context.refresh.ContextRefresher;
//import org.springframework.cloud.endpoint.event.RefreshEvent;
//import org.springframework.context.ApplicationEvent;
//import org.springframework.context.event.SmartApplicationListener;
//
//import java.util.Set;
//import java.util.concurrent.atomic.AtomicBoolean;
//
//@WebListener
//public class RefreshEventListener implements SmartApplicationListener {
//    private static Log log = LogFactory.getLog(RefreshEventListener.class);
//    private ContextRefresher refresh;
//    private AtomicBoolean ready = new AtomicBoolean(false);
//
//    public RefreshEventListener(ContextRefresher refresh) {
//        this.refresh = refresh;
//    }
//
//    @Override
//    public boolean supportsEventType(Class<? extends ApplicationEvent> eventType) {
//        return ApplicationReadyEvent.class.isAssignableFrom(eventType) || RefreshEvent.class.isAssignableFrom(eventType);
//    }
//
//    @Override
//    public void onApplicationEvent(ApplicationEvent event) {
//        if (event instanceof ApplicationReadyEvent) {
//            this.handle((ApplicationReadyEvent)event);
//        } else if (event instanceof RefreshEvent) {
//            this.handle((RefreshEvent)event);
//        }
//
//    }
//
//    public void handle(ApplicationReadyEvent event) {
//        this.ready.compareAndSet(false, true);
//    }
//
//    public void handle(RefreshEvent event) {
//        if (this.ready.get()) {
//            log.debug("Event received " + event.getEventDesc());
//            Set<String> keys = this.refresh.refresh();
//            log.info("Refresh keys changed: " + keys);
//        }
//
//    }
//}
